//
//  RotateAsGroupAction.cpp
//  fingeradvanture
//
//  Created by shuaibincheng on 16/5/29.
//
//

#include "RotateAsGroupAction.hpp"
#include "TroopForm.hpp"

void RotateAsGroupAction::train(const Vector<cocos2d::Node *> &monsters)
{
    for(auto it = monsters.begin(); it != monsters.end(); it++)
    {
        auto rotationAction = RotateBy::create(5, 360.0f);
        auto repeatAction = Repeat::create(rotationAction, 10);
        
        auto downMoveBy = MoveBy::create(15.0f, Vec2(0.0f, -form->getVisibleSize().height
                                                     - form->getTroopSize().height - 20));
        
        auto spawn = Spawn::create(repeatAction, downMoveBy, NULL);
        (*it)->runAction(spawn);
    }
}